home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: 22 Feb 1996 19:58:44 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4gihtk$33k@sun001.spd.dsccc.com>
- References: <Dn1C9z.DGv.0.net@indra.com> <1996Feb1922.17.19.879@koobera.math.uic.edu>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <1996Feb1922.17.19.879@koobera.math.uic.edu>,
- D. J. Bernstein <djb@koobera.math.uic.edu> wrote:
- )Steve Sullivan <sullivan@indra.com> wrote:
- )> i = j + k;
- )> if (overflowed) ....;
- )
- )A smart compiler will optimize ``if (i < j)''---I'm assuming here that
- )all variables are unsigned---into a test of the carry bit.
-
- Depends on which (if any) of i and j are unsigned whether that is even
- the correct test. Unsigned overflow should check the carry bit. Signed
- overflow must test for a carry out of a different bit. Also, your
- statement actually depends on having complement arithmetic, rather than
- signed magnitude. This is a difficult problem, and such checks are
- going to be s-l-o-w. There are machines which provide hardware traps on
- integer overflow.
-
- )(I've been saying for years that every compiler should provide a
- )_documented_ idiom for every possible machine-language operation.)
- )
- )---Dan
-
-
- HMMMM.
-
- Mike
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-